home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML Authority.sea / XML Authority / Required / tamino / TaminoLib.js < prev   
Encoding:
Text File  |  2000-05-03  |  20.6 KB  |  743 lines  |  [BINA/hDmp]

  1. //For use with ASP replace this line with
  2. //Tamino Java Script Object for IE5.0
  3. //Software AG -Technical Services
  4. //Nigel W. O. Hutchison 
  5.  
  6. var inoVersion="1.2.1.2";
  7.  
  8. var inoUserAgent="Tamino Client/Java Script/IE5.0 ";
  9. var inoVersion="1.2.1.1";
  10. var inoErrorText= new Array();
  11. var inoEnoErrorBase=8400;
  12. var inoComponent="INOXJE";
  13. var inoTransportErrorNo=inoEnoErrorBase+0;
  14.     inoErrorText[0]="HTTP Error ";
  15. var inoParserErrorNo=inoEnoErrorBase+1;
  16.     inoErrorText[1]="Parser Error ";
  17. var inoSessionOpenErrorNo=inoEnoErrorBase+2;
  18.     inoErrorText[2]="Session already open";
  19. var inoSessionNotOpenErrorNo=inoEnoErrorBase+3;
  20.      inoErrorText[3]="No session open";
  21. var inoSessionFailureErrorNo=inoEnoErrorBase+4;
  22.     inoErrorText[4]="No session established";
  23. var inoURLdidNotExistNo=inoEnoErrorBase+5;
  24.     inoErrorText[5]="URL did not exist";
  25. var inoDeleteNotSpecifiedNo=inoEnoErrorBase+6;
  26.     inoErrorText[6]="Document to be Deleted not Specified";
  27. var inoInvalidNodeTypeNo=inoEnoErrorBase+7;
  28.     inoErrorText[7]="Invalid Node Type";
  29. var inoSessionIdErrorNo=inoEnoErrorBase+8;
  30.     inoErrorText[8]="Invalid sessionID received from Server";
  31. var inoNoXMLErrorNo=inoEnoErrorBase+9;
  32.     inoErrorText[9]="No Tamino Response Returned";
  33.  
  34. //Microsoft XMLDOM node constants
  35. var NODE_ELEMENT=1;
  36. var NODE_ATTRIBUTE = 2; 
  37. var NODE_TEXT = 3; 
  38. var NODE_CDATA_SECTION = 4; 
  39. var NODE_ENTITY_REFERENCE =5; 
  40. var NODE_ENTITY = 6; 
  41. var NODE_PROCESSING_INSTRUCTION =7; 
  42. var NODE_COMMENT = 8; 
  43. var NODE_DOCUMENT = 9; 
  44. var NODE_DOCUMENT_TYPE = 10; 
  45. var NODE_DOCUMENT_FRAGMENT = 11; 
  46. var NODE_NOTATION = 12; 
  47.  
  48.  function TaminoClient()
  49. {
  50.     //define properties
  51.     this.XMLDB =""; 
  52.     this.securePath="";
  53.     this.lastQuery=""; //f2
  54.     this.pageSize=5;
  55.     this.user="";
  56.     this.password="";
  57.     this.transaction=null;
  58.     this.xmlHeader='<?xml version="1.0"?>'; //default - UTF-8;
  59.     this.userAgent=inoUserAgent+inoVersion;
  60.     this.acceptLanguage="en";
  61.     this.charset="utf-8";
  62.     this.acceptCharset="utf-8";
  63.     var argv=arguments;
  64.     var argc=arguments.length;
  65.     if    (argc > 0)
  66.         {
  67.         this.XMLDB=argv[0];
  68.         }
  69.     if    (argc > 1)
  70.         this.pageSize=arguments[1];
  71.     if    (argc > 2)
  72.         this.user=arguments[2];
  73.     if    (argc > 3)
  74.         this.password=arguments[3];    
  75.     
  76.     
  77.     
  78.     
  79. function TaminoTransaction()  //transaction class
  80.     {
  81.     this.tid = null;
  82.     this.key = null;
  83.     this.errorNo=0;
  84.     this.errorText="";
  85.     if    (arguments.length> 0) this.tid=arguments[0];
  86.     if    (arguments.length> 1) this.key=arguments[1];
  87.     }
  88.  
  89.  
  90. function TaminoResult(queryo,req,noBody) //result class
  91. {
  92.     //define properties
  93.     
  94.     
  95.     this.queryObj=queryo;
  96.     
  97.     this.REQ=req;
  98.     this.DOM=null;
  99.     this.lastQuery="";
  100.     this.pageSize=5;
  101.     this.user="";
  102.     this.password="";
  103.     this.errorNo=0;
  104.     this.errorText=""; 
  105.     this.securePath=queryo.securePath;
  106.         
  107.     if    (this.REQ)
  108.         {
  109.         var status = this.REQ.status;
  110.         if    (status >= "300")
  111.             {
  112.             this.errorNo=inoTransportErrorNo;
  113.             this.errorText=TaminoClientErrorText(inoTransportErrorNo,status,this.REQ.statusText);
  114.             }
  115.         else      { 
  116.             //this.DOM=new ActiveXObject("Microsoft.XMLDOM");
  117.             //should we check if there is a response entity?
  118.             if    (noBody)return;
  119.             
  120.             this.DOM=this.REQ.responseXML;
  121.             if    (!this.DOM.documentElement)
  122.                 {
  123.                 this.errorNo=inoNoXMLErrorNo;
  124.                 this.errorText=TaminoClientErrorText(inoNoXMLErrorNo);
  125.                 return;
  126.                 }
  127.             var p = this.DOM.parseError;
  128.             if    ( p.errorCode!="0")
  129.                 {
  130.                 this.errorNo=inoParserErrorNo;
  131.                 this.errorText=TaminoClientErrorText(inoParserErrorNo,
  132.                      p.errorCode,p.reason);
  133.                 }
  134.             else    {
  135.                 var message = this.ErrorNode();
  136.                 
  137.                 if (message)
  138.                     {
  139.                     this.errorNo=Number(message.getAttribute("ino:returnvalue"));
  140.                     var node = message.selectSingleNode("ino:messagetext");
  141.                     var text=this.errorNo;
  142.                     if (node) text= node.getAttribute("ino:code")+" "+node.text;                        text= node.getAttribute("ino:code")
  143.                             +" "+node.text;
  144.                     var lines=message.selectNodes("ino:messageline");
  145.                     if    (lines)
  146.                         {
  147.                         var l=lines.length;
  148.                         for (var j=0;j<l;j++)
  149.                             {
  150.                             var line =lines.item(j);
  151.                             text=text+', '+line.text;
  152.                             }
  153.                         }
  154.                     this.errorText=text;
  155.                     }
  156.                         
  157.                 var tran = this.queryObj.transaction;
  158.                 if    (tran)
  159.                     {
  160.                     if    (!tran.update(this.DOM))
  161.                         {
  162.                         this.errorNo=
  163.                             tran.errorNo;
  164.                         this.errorText=
  165.                             tran.errorText;
  166.                         }
  167.                     }
  168.                 }
  169.                 
  170.                     
  171.             }
  172.         }
  173.  
  174.  
  175. TaminoClient.prototype.query= function (xqlquery)
  176. {
  177.     var cursor;
  178.     var pageSize= parseInt(this.pageSize);
  179.     if    (pageSize>0)
  180.         cursor="?_XQL(1,"+pageSize+")="+this.escape(xqlquery);
  181.     else     cursor="?_XQL="+this.escape(xqlquery);
  182.     if     (arguments.length > 1)
  183.         return(this.queryCursor(cursor,arguments[1]));
  184.     else    return(this.queryCursor(cursor));
  185. }
  186. TaminoClient.prototype.queryCursor=function(cursorQuery)
  187. {
  188.     var extraPath = "";
  189.     if    (arguments.length > 1)
  190.         extraPath=arguments[1];
  191.     var session= this.tEncoded();
  192.     if    (session !="") session="&"+session;
  193.     this.lastQuery=this.XMLDB+extraPath+cursorQuery+session;
  194.     
  195.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  196.     REQ.open("GET",this.lastQuery,
  197.         false,this.user,this.password);
  198.     REQ.setRequestHeader("User-Agent",this.userAgent);
  199.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  200.     REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  201.     REQ.setRequestHeader("Cache-Control","no-cache");
  202.     //REQ.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+this.charset);
  203.     REQ.send("");
  204.     var result = new TaminoResult(this,REQ);
  205.     result.lastCursor=cursorQuery;
  206.     return(result);
  207. }
  208. TaminoClient.prototype.querydelete=function(query)
  209. {
  210.     if     (arguments.length > 1)
  211.         this.lastQuery=this.XMLDB+arguments[1];
  212.     else   this.lastQuery=this.XMLDB+this.securePath;
  213.     var clause =this.escape(query)
  214.     var session=this.tEncoded();
  215.     if    (session != "") session="&"+session;
  216.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  217.     REQ.open("POST",this.lastQuery,false,this.user,this.password);
  218.     REQ.setRequestHeader("User-Agent",this.userAgent);
  219.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  220.     REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  221.     //REQ.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+this.charset);
  222.     REQ.send("_DELETE="+clause+session);
  223.     var result = new TaminoResult(this,REQ);
  224.     return(result);
  225. }
  226. TaminoClient.prototype.inodelete=function(node)
  227. {
  228.     if    (node && (node.nodeType == NODE_ELEMENT
  229.             || node.nodeType == NODE_DOCUMENT))
  230.         {
  231.         
  232.         var clause = node.nodeName+'[@ino:id="'
  233.             +node.getAttribute("ino:id")+'"]';
  234.         if     (arguments.length > 1)
  235.             return(this.querydelete(clause,arguments[1]));
  236.         else     return(this.querydelete(clause));
  237.         }
  238.     else    {
  239.         var result = new TaminoResult(this,null);
  240.         result.erroNo=inoDeleteNotSpecifiedNo;
  241.         result.errorText=TaminoClientErrorText(inoDeleteNotSpecifiedNo);
  242.         }
  243.     return(result);
  244. }
  245. TaminoClient.prototype.escape=function(myString)
  246. {
  247. var out="";
  248. var length=myString.length;
  249. for (var i=0;i<length;i++)
  250.     {
  251.     var char = myString.charAt(i);
  252.     var val=char.charCodeAt(0);
  253.     if    (val > 255)
  254.         {
  255.         out = out + "&#"+val+";";
  256.         }
  257.     else     {
  258.         out=out+char;
  259.         }
  260.     }
  261. return(escape(out));
  262. }
  263. TaminoClient.prototype.absoluteURL=function(reurl)
  264.     {
  265.     //check if URL is absolute
  266.     var urlPattern=/^http:/;
  267.     if    (reurl.match(urlPattern)!= null)
  268.         return(reurl);
  269.     else    return(this.XMLDB+"/"+reurl);
  270.     }
  271. TaminoClient.prototype.deleteDocument= function (reurl)
  272. {
  273.     this.lastQuery=this.absoluteURL(reurl);
  274.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  275.     REQ.open("DELETE",this.lastQuery,false,this.user,this.password);
  276.     REQ.setRequestHeader("User-Agent",this.userAgent);
  277.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  278.         REQ.send("");
  279.     var result=new TaminoResult(this,REQ,true);
  280.     return(result);
  281. }
  282. TaminoClient.prototype.getDocument=function (reurl)
  283. {
  284.     this.lastQuery=this.absoluteURL(reurl);
  285.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  286.     REQ.open("GET",this.lastQuery,false,this.user,this.password);
  287.     REQ.setRequestHeader("User-Agent",this.userAgent);
  288.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  289.     REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  290.     REQ.setRequestHeader("Cache-Control","no-cache");
  291.     REQ.send("");
  292.     var result=new TaminoResult(this,REQ);
  293.     return(result);
  294. }    
  295. TaminoClient.prototype.putDocument=function (reurl,node)
  296. {
  297.     var header;
  298.     this.lastQuery=this.absoluteURL(reurl);
  299.     if    (node.nodeType == NODE_ELEMENT)
  300.         header = this.xmlHeader;
  301.     else     {if (node.nodeType == NODE_DOCUMENT)
  302.             header="";
  303.         else {
  304.             var r = new TaminoResult(this,null);
  305.             r.errorNo=inoInvalidNodeTypeNo;
  306.             r.errorText=TaminoClientErrorText(inoInvalidNodeTypeNo,node.nodeType);
  307.             return(r);
  308.              }
  309.         }
  310.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  311.     REQ.open("PUT",this.lastQuery,false,this.user,this.password);
  312.     REQ.setRequestHeader("User-Agent",this.userAgent);
  313.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  314.     REQ.setRequestHeader("Content-Type","text/xml; charset="+this.charset);
  315.     REQ.send(header+node.xml);
  316.     var result=new TaminoResult(this,REQ,true);
  317.     return(result);
  318. }
  319. TaminoClient.prototype.head=function (reurl)
  320. {
  321.     this.lastQuery=this.absoluteURL(reurl);
  322.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  323.     REQ.open("HEAD",this.lastQuery,false,this.user,this.password);
  324.     REQ.setRequestHeader("User-Agent",this.userAgent);
  325.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  326.     REQ.send("");
  327.     var result=new TaminoResult(this,REQ,true);
  328.     return(result);
  329. }
  330.         
  331. TaminoClient.prototype.process=function(node)
  332.     {
  333.     var header;
  334.     var nodeType=node.nodeType;
  335.     if    (nodeType == NODE_ELEMENT)
  336.         header = this.xmlHeader;
  337.     else     {if (nodeType == NODE_DOCUMENT)
  338.             header="";
  339.         else {
  340.             var r = new TaminoResult(this,null);
  341.             r.errorNo=inoInvalidNodeTypeNo;
  342.             r.errorText=TaminoClientErrorText(inoInvalidNodeTypeNo,nodeType);
  343.             return(r);
  344.              }
  345.         }
  346.     
  347.     if     (arguments.length > 1)
  348.         this.lastQuery=this.XMLDB+arguments[1];
  349.     else   this.lastQuery=this.XMLDB+this.securePath;
  350.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  351.     REQ.open("POST",this.lastQuery,false,this.user,this.password);
  352.     var session=this.tEncoded();
  353.     if    (session) session=session+"&";
  354.     REQ.setRequestHeader("User-Agent",this.userAgent);
  355.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  356.     REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  357.     REQ.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+this.charset);
  358.     REQ.send(session+"_PROCESS="+this.escape(header+node.xml));
  359.     var r = new TaminoResult(this,REQ);
  360.     return(r);
  361. }
  362.  
  363. TaminoResult.prototype.cursor=function(attr)
  364.     {
  365.     var query = this.getCursorQuery(attr);
  366.     
  367.     if    (query)    return(this.queryObj.queryCursor(query));
  368.     return(this); 
  369. }
  370. TaminoResult.prototype.rObject= function()
  371. {
  372.     var rObjNodelist =this.DOM.getElementsByTagName("ino:object");
  373.     if      (rObjNodelist)return(rObjNodelist.item(0));
  374.     return(null);
  375. }
  376. TaminoResult.prototype.getInoId=function ()
  377. {
  378.     var rObj = this.rObject();
  379.     if    (rObj) return(rObj.getAttribute("ino:id"));
  380.     return(null);
  381. }
  382. TaminoResult.prototype.getDocType=function ()
  383. {
  384.     var rObj = this.rObject();
  385.     if    (rObj)    return(rObj.getAttribute("ino:doctype"));
  386.     return(null);
  387. }
  388. TaminoResult.prototype.getCollection=function ()
  389. {
  390.     var rObj = this.rObject();
  391.     if    (rObj)    return(rObj.getAttribute("ino:collection"));
  392.     return(null);
  393. }
  394. TaminoResult.prototype.getLocation=function()
  395. {
  396.     var location = this.REQ.getResponseHeader("Location");
  397.     if    (location) return (location);
  398.     var collection = this.getCollection();
  399.     var docType = this.getDocType();
  400.     var inoId= this.getInoId();
  401.     if    (collection && docType && inoId)        
  402.         return(this.queryObj.XMLDB+"/"+collection+"/"+docType+"/@"+inoId);
  403.     return(null);
  404.     }
  405.  
  406. TaminoResult.prototype.ErrorNode=function()
  407. {
  408.     var messages=this.DOM.getElementsByTagName("ino:message");
  409.     var messagesLength=messages.length;
  410.     var message;
  411.     var i;
  412.     var returnCode;
  413.     for     (i=0;i<messagesLength;i++)
  414.         {
  415.         message=messages.item(i);
  416.         returnCode = message.getAttribute("ino:returnvalue");
  417.         if    (returnCode!="0") return(message);
  418.         }
  419.     return(null);
  420. }
  421.  
  422.     
  423.  
  424. TaminoResult.prototype.nodes=function ()
  425.     {
  426.     var result = this.DOM.getElementsByTagName("xql:result").item(0);
  427.     if    (result) return(result.childNodes);
  428.     return(null);
  429.     }
  430. TaminoResult.prototype.getResult=function ()
  431.     {
  432.     var result = this.DOM.getElementsByTagName("xql:result").item(0);
  433.     return(result);
  434.     }
  435. TaminoResult.prototype.getFirst=function (){
  436.     return(this.cursor("first"));
  437.     }
  438. TaminoResult.prototype.getPrev=function (){
  439.     return(this.cursor("prev"));
  440.     }
  441. TaminoResult.prototype.getNext=function (){
  442.     
  443.     return(this.cursor("next"));
  444.     }
  445. TaminoResult.prototype.getLast=function (){
  446.     return(this.cursor("last"));
  447. }
  448. TaminoResult.prototype.refresh=function(){
  449.     if    (!this.lastCursor) return(this);
  450.     return(this.queryObj.queryCursor(this.lastCursor));
  451. }
  452.  
  453. TaminoResult.prototype.getCursorQuery=function (attr)
  454. {
  455.     var link = this.DOM.getElementsByTagName("ino:"+attr).item(0);
  456.     if    (link) return(link.getAttribute("ino:href"));
  457.     return("");
  458. }
  459. TaminoResult.prototype.getTotalCount=function()
  460. {
  461.     var doc;
  462.     var cursorList;
  463.     var nodes;
  464.     if    (doc=this.DOM)
  465.         {
  466.         if    (cursorList=doc.getElementsByTagName("ino:cursor"))
  467.             return(cursorList.item(0).getAttribute("ino:count"));
  468.         if    (nodes=this.nodes())
  469.             return(nodes.length);
  470.         }
  471.     return(null);
  472. }
  473. TaminoClient.prototype.insert=function (node)
  474. {
  475.     //clear ino:id
  476.     node.attributes.removeNamedItem("ino:id");
  477.     if    (arguments.length > 1)
  478.         return(this.process(node,arguments[1]));
  479.     return(this.process(node));
  480. }
  481. TaminoClient.prototype.update =function (node,inoid)
  482. {
  483.     //override inoId if it exists
  484.     inoidNode=node.ownerDocument.createAttribute("ino:id");
  485.     node.attributes.setNamedItem(inoidNode);
  486.     inoidNode.nodeValue=inoid;
  487.     if    (arguments.length > 2)
  488.         return(this.process(node,arguments[2]));
  489.     return(this.process(node));
  490. }
  491. TaminoClient.prototype.inoDoCommand=function(command,tidParam)
  492.     {
  493.     this.lastQuery=this.XMLDB+this.securePath;
  494.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  495.     REQ.open("POST",this.lastQuery,false,this.user,this.password);
  496.     //REQ.open("GET","http://pctamino2/tamino/newDB?_connect=*",false,this.user,this.password);
  497.     REQ.setRequestHeader("User-Agent",this.userAgent);
  498.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  499.     REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  500.     REQ.send(command+"=*&"+tidParam);    
  501.     result=new TaminoResult(this,REQ);
  502.     return(result);
  503.     }
  504. function TaminoClientErrorText(code)
  505.     {
  506.     var parameters="";
  507.     var l= arguments.length;
  508.     for(var i=1;i<l;i++){ parameters=parameters+" " + arguments[i];    }    
  509.     return (inoComponent+code+" "+inoErrorText[code-inoEnoErrorBase]+parameters);
  510.     //this should get the error text from the server if the langauge is not right
  511.     
  512.     }
  513. TaminoClient.prototype.SessionError=function(code)
  514.     {
  515.     var result= new TaminoResult(this,null);
  516.     result.errorNo=code;
  517.     result.errorText=TaminoClientErrorText(code);
  518.     return(result);            
  519.     }
  520.  
  521. TaminoClient.prototype.startSession= function ()
  522.     {
  523.     //test
  524.     if    (this.transaction!=null)
  525.         {
  526.         return(this.SessionError(inoSessionOpenErrorNo));
  527.         }
  528.     var result = this.inoDoCommand("_connect","");
  529.     
  530.     if    (!result.errorNo)
  531.         {
  532.         var root=result.DOM.getElementsByTagName("ino:response").item(0);
  533.         if    (root)
  534.             {
  535.             var tid = root.getAttribute("ino:sessionid");
  536.             var key = root.getAttribute("ino:sessionkey");
  537.             if    (tid && key)
  538.                 {
  539.                 this.errorNo=0;
  540.                 this.transaction=new TaminoTransaction(tid,key);
  541.                 return(result);
  542.                 }
  543.             }
  544.         result.errorNo=inoSessionFailureErrorNo;
  545.         result.errorText=TamTaminoClientErrorText(inoSessionFailureErrorNo);
  546.                 
  547.         }
  548.     return(result);
  549. }
  550. TaminoClient.prototype.endSession=function ()
  551.     {
  552.     var result;
  553.     if    (!this.transaction)
  554.         {
  555.         return(this.SessionError(inoSessionNotOpenErrorNo));
  556.           }
  557.     result = this.inoDoCommand("_disconnect",this.tEncoded());
  558.     this.transaction=null;
  559.     return(result);
  560. }
  561. TaminoClient.prototype.commit= function ()
  562.     {
  563.     var result;
  564.     if    (!this.transaction)
  565.         {
  566.         return(this.SessionError(inoSessionNotOpenErrorNo));
  567.           }
  568.     result=this.inoDoCommand("_commit",this.tEncoded());
  569.     return(result);
  570. }
  571. TaminoClient.prototype.rollback=function ()
  572.     {
  573.     var result;
  574.     if    (!this.transaction)
  575.         {
  576.         return(this.SessionError(inoSessionNotOpenErrorNo));
  577.           }
  578.     result = this.inoDoCommand("_rollback",this.tEncoded());
  579.     return(result);
  580.     }
  581.  
  582.  
  583. TaminoClient.prototype.tEncoded=function () 
  584.     {
  585.     if    (this.transaction)
  586.         return(this.transaction.encoded());
  587.     else    return("");
  588. }        
  589. TaminoClient.prototype.setEncoding=function(encoding)
  590.     {
  591.     if    (encoding == "")
  592.         {
  593.         this.xmlHeader='<?xml version="1.0"?>';
  594.         }
  595.     else    {
  596.         this.xmlHeader='<?xml version="1.0" encoding="'+encoding+'"?>';
  597.         }
  598.     }
  599. TaminoClient.prototype.setUserPassword=function(user,password)
  600.     {
  601.     this.user=user;
  602.     this.password=password;
  603.     }
  604.  
  605.  
  606. TaminoTransaction.prototype.encoded=
  607.     function(){return("_sessionid="+this.tid+"&_sessionkey="+this.key);}
  608.  
  609. TaminoTransaction.prototype.update=function(node)
  610. {
  611.     var root=node.getElementsByTagName("ino:response").item(0);
  612.     var tid;
  613.     var key;
  614.     if    (root)
  615.         {
  616.         tid =root.getAttribute("ino:sessionid");
  617.         key = root.getAttribute("ino:sessionkey");
  618.         
  619.         if    (this.tid == tid)
  620.             {
  621.             this.key=key;
  622.             this.errorNo=0;
  623.             this.errorText="";
  624.             return(true); 
  625.             }
  626.         }
  627.     else tid="no root";
  628.     this.errorNo=inoSessionIdErrorNo;
  629.     this.errorText=TaminoClientErrorText(inoSessionIdErrorNo,tid,key);
  630.     return(false);
  631. }
  632.     
  633. TaminoClient.prototype.define=function(node)
  634.     {
  635.     
  636.     var REQ=new ActiveXObject("Microsoft.XMLHTTP");
  637.     this.lastQuery=this.XMLDB;
  638.     REQ.open("POST",this.lastQuery,false,this.user,this.password);
  639.     REQ.setRequestHeader("User-Agent",this.userAgent);
  640.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  641.     REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  642.     REQ.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+this.charset);
  643.     REQ.send("_define="+this.escape(this.xmlHeader+node.xml));
  644.     result=new TaminoResult(this,REQ);
  645.     return(result);
  646. }
  647. TaminoClient.prototype.undefine=function(query)
  648.     {
  649.     var REQ=new ActiveXObject("Microsoft.XMLHTTP");
  650.     this.lastQuery=this.XMLDB;
  651.     REQ.open("POST",this.lastQuery,false,this.user,this.password);
  652.     REQ.setRequestHeader("User-Agent",this.userAgent);
  653.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  654.     REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  655.     REQ.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+this.charset);
  656.     REQ.send("_undefine="+this.escape(query));
  657.     result=new TaminoResult(this,REQ);
  658.     return(result);
  659.     }
  660.         
  661. TaminoClient.prototype.loadChildren=function(node)
  662.     {
  663.     var elements=node.childNodes;
  664.     var length=elements.length;
  665.     var index=0;
  666.     var buffer = "";
  667.     var errorNo=0;
  668.     var maxBunch=this.maxBunch;
  669.     var REQ;
  670.     var result;
  671.     if    (arguments.length > 1) maxBunch=arguments[1];
  672.     if    (!maxBunch) maxBunch=100;
  673.     this.lastQuery=this.XMLDB;
  674.     while (!errorNo && index < length)
  675.         {
  676.         var bunch = 0;
  677.         buffer="";
  678.         while     (!errorNo && bunch<maxBunch && index<length)
  679.             {
  680.             buffer=buffer+elements.item(index).xml;
  681.             bunch++;
  682.             index++;
  683.             }
  684.         if (!errorNo && bunch)
  685.             {
  686.             REQ=new ActiveXObject("Microsoft.XMLHTTP");
  687.             REQ.open("POST",this.lastQuery,false,this.user,this.password);
  688.             var session=this.tEncoded();
  689.             if    (session) session=session+"&";
  690.             REQ.setRequestHeader("User-Agent",this.userAgent);
  691.             REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  692.             REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  693.             REQ.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+this.charset);
  694.             REQ.send(session+"_PROCESS="+this.escape(this.xmlHeader+buffer));
  695.             result=new TaminoResult(this,REQ);
  696.             errorNo=result.errorNo;
  697.             }
  698.         }
  699.     if    (!result)
  700.         result=new TaminoResult(this);//should give a zero set
  701.         
  702.     return(result);    
  703.     }
  704. TaminoClient.prototype.remoteUpdate=function(verb,reurl,xPath,node)
  705.     {
  706.     var payload="";
  707.     var nodeType=node.nodeType;
  708.     if    (node && node.nodeType != NODE_ELEMENT)
  709.         {
  710.             var r = new TaminoResult(this,null);
  711.             r.errorNo=inoInvalidNodeTypeNo;
  712.             r.errorText=TaminoClientErrorText(inoInvalidNodeTypeNo,node.nodeType);
  713.             return(r);
  714.         }
  715.     if    (node)
  716.         {
  717.         payload="&_newnode="+this.escape(this.header+node.xml);
  718.         }
  719.     this.lastQuery=this.XMLDB;
  720.     REQ=new ActiveXObject("Microsoft.XMLHTTP");
  721.     REQ.open("POST",this.lastQuery,false,this.user,this.password);
  722.     var session=this.tEncoded();
  723.     if    (session) session=session+"&";
  724.     REQ.setRequestHeader("User-Agent",this.userAgent);
  725.     REQ.setRequestHeader("Accept-Language",this.acceptLanguage);
  726.     REQ.setRequestHeader("Accept-Charset",this.acceptCharset);
  727.     REQ.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset="+this.charset);
  728.     REQ.send(session+verb+"="+reurl+"&_xpath="+this.escape(xPath)+payload);
  729.     var r = new TaminoResult(this,REQ);
  730.     return(r);
  731. }
  732. TaminoClient.prototype.insertBefore=function(reurl,xpath,node)
  733. {return(this.remoteUpdate("_insertBefore",reurl,xpath,node));}
  734. TaminoClient.prototype.appendChild=function(reurl,xpath,node)
  735. {return(this.remoteUpdate("_appendChild",reurl,xpath,node));}
  736. TaminoClient.prototype.replaceNode=function(reurl,xpath,node)
  737. {return(this.remoteUpdate("_replaceNode",reurl,xpath,node));}
  738. TaminoClient.prototype.insertBefore=function(reurl,xpath)
  739. {return(this.remoteUpdate("_removeNode",reurl,xpath));}
  740.  
  741. //For use with ASP replace this line with